package com.bdqn.crm.controller;

import com.bdqn.crm.pojo.PageBean;
import com.bdqn.crm.pojo.Pagee;
import com.bdqn.crm.pojo.SysRole;
import com.bdqn.crm.service.SysRoleService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class SysRoleController {
    @Resource
    private SysRoleService sysRoleService;

    @RequestMapping(value = "role/list")
    public String list(Model model,@RequestParam(value = "roleName",required = false)String roleName,
                       @RequestParam(value = "pageIndex",defaultValue = "1")int pageIndex){

        model.addAttribute("roleName",roleName);
        Pagee<SysRole> pageBean = sysRoleService.page(roleName,pageIndex);
        model.addAttribute("rolePage",pageBean);
        return "role/list";
    }
    @GetMapping(value = "role/edit")
    public String edit(){

        return "role/list";
    }
}
